package sword_to_1;

import node.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_54 {
    public static void main(String[] args) {

    }
    private static int kthLargest(TreeNode root, int k) {
        List<Integer> list = new ArrayList<>();
        dfs(root, k, list);
        return list.get(k - 1);
    }
    private static void dfs(TreeNode node, int n, List<Integer> list){
        if (node == null){
            return;
        }
        dfs(node.right, n, list);
        list.add(node.val);
        if (list.size() >= n){
            return;
        }
        dfs(node.left, n, list);
    }
}
